from .wikipedia_services import (
    WikipediaQueryPageByTitleAsyncService, 
    WikipediaQueryWikiTextByTitleAsyncService,
    WikipediaQueryPageByPageIDAsyncService,
    WikipediaQueryCategoryMemberByTitleAsyncService,
)
from .wikidata_services import (
    WikidataQueryEntityByQidAsyncService,
    WikidataSparqlAsyncService,
)
# 创建全局服务实例

wikipage_by_pageid_service = WikipediaQueryPageByPageIDAsyncService(batch_size=20)
wikipage_by_title_service = WikipediaQueryPageByTitleAsyncService(batch_size=20)
wikitext_by_title_service = WikipediaQueryWikiTextByTitleAsyncService()
wikidata_by_qid_service = WikidataQueryEntityByQidAsyncService(batch_size=15)
wiki_category_members_service = WikipediaQueryCategoryMemberByTitleAsyncService()
wikidata_sparql_service = WikidataSparqlAsyncService()

# 初始化函数，在应用启动时调用
async def initialize_service():
    await wikipage_by_title_service.initialize()
    await wikitext_by_title_service.initialize()
    await wikidata_by_qid_service.initialize()
    await wikipage_by_pageid_service.initialize()
    await wiki_category_members_service.initialize()
    await wikidata_sparql_service.initialize()

async def shutdown_service():
    await wikipage_by_title_service.shutdown()
    await wikitext_by_title_service.shutdown()
    await wikidata_by_qid_service.shutdown()
    await wikipage_by_pageid_service.shutdown()
    await wiki_category_members_service.shutdown()
    await wikidata_sparql_service.shutdown()



__all__ = [
    "wikipage_by_title_service",
    "wikitext_by_title_service",
    "wikipage_by_pageid_service",
    "wikidata_sparql_service",
    "wikidata_by_qid_service",
    "wiki_category_members_service",
]